package com.topvision.myviewtest.camera;

import android.util.Log;

public class LogUtil {
    private static boolean SHOW_DEBUG = true;
    private static final String TAG = "LogUtil";

    public LogUtil() {
    }

    public static void Enable(boolean enable) {
        SHOW_DEBUG = enable;
    }

    public static void d(String tag, String msg) {
        if (SHOW_DEBUG) {
            Log.d(tag, msg);
        }
    }

    public static void d(String msg) {
        if (SHOW_DEBUG) {
            Log.d(TAG, msg);
        }
    }

    public static void trace() {
        if (SHOW_DEBUG) {
            StackTraceElement element = Thread.currentThread().getStackTrace()[3];
            Log.d(TAG, "Class: " + element.getClassName() + " Method: " + element.getMethodName());
        }
    }

    public static void e(Exception e) {
        StackTraceElement element = e.getStackTrace()[0];
        Log.e(TAG, "Caught Exception in Class: " + element.getClassName() + "\r\nMethod: " + element.getMethodName() + "()\r\nMessage: " + e.getMessage());
    }

    public static void e(String msg) {
        Log.e(TAG, msg);
    }
}
